#!/usr/bin/env bash
# */5 * * * * /data/app/schedule-monitor/check_pid.sh >> /data/app/schedule-monitor/check_pid.log 2>&1
PID=$(ps aux | grep -v grep | grep -i java |grep -i schedule-monitor | awk '{print $2}')

if [[ "X${PID}" != "X" ]] && [[ ${PID} -gt 0 ]] && kill -0 ${PID} > /dev/null 2>&1; then
    echo "[$(date +'%Y-%m-%d %H:%M:%S.%N')] scheduler-monitor is running as process ${PID}."
    exit 0
else
    echo "scheduler-monitor is not running"
    curl "http://172.18.33.94:8154/send/msg?phones=15882439584&msg=$(hostname -i)%20($(hostname))%20scheduler-monitor%20shutdown!"
fi